﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeCamp12.DAL;
using log4net;
using System.IO;
using CodeCamp12.Domain;

namespace CodeCamp12.BLL
{
    public class AdditionalBL
    {
        private ILog log = LogManager.GetLogger("CodeCamp12.BLL");

        /// <summary>
        /// Updates the link for contributors page
        /// </summary>
        /// <param name="link"></param>
        public void UpdateContributors(string link)
        {

            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
               additionalDataProvider.UpdateContributors(link);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Updates the facebook icon link
        /// </summary>
        /// <param name="link"></param>
        public void UpdateFacebook(string link)
        {
            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
                additionalDataProvider.UpdateFacebook(link);
            }
            catch (Exception ex)
            {
                
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Updates the master page top logo
        /// </summary>
        /// <param name="image"></param>
        public void UpdateLogo(Stream image)
        {
            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
                additionalDataProvider.UpdateLogo(image);
            }
            catch (Exception ex)
            {
                
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Updates the twitter icon link
        /// </summary>
        /// <param name="link"></param>
        public void UpdateTwitter(string link)
        {
            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
                additionalDataProvider.UpdateTwitter(link);
            }
            catch (Exception ex)
            {
                
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Updates the home page video 
        /// </summary>
        /// <param name="link"></param>
        public void UpdateYouTube(string link)
        {
            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
                additionalDataProvider.UpdateYouTubeVideo(link);
            }
            catch (Exception ex)
            {
                
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Updates the linkedin icon link
        /// </summary>
        /// <param name="link"></param>
        public void UpdateLinkedin(string link)
        {
            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
                additionalDataProvider.UpdateLinkedinLink(link);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Gets all the additional properties
        /// </summary>
        /// <returns></returns>
        public OtherProperties GetAdditionalStuff()
        {
            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
                return additionalDataProvider.GetAdditionalStuff();
            }
            catch (Exception ex)
            {
                
                log.Error(ex);
                throw;
            }
        }
        
        /// <summary>
        /// Gets the logo image for the website
        /// </summary>
        /// <returns></returns>
        public Stream GetLogo()
        {
            var additionalDataProvider = new AdditionalDataManagement();
            try
            {
                return additionalDataProvider.GetLogo();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }

    }
}
